<?php


namespace app\api\controller;


use app\common\controller\Api;

class LifeServices extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];



    /**
     * 获取分类列表
     */
    public function getCatList(\app\common\model\lifeservices\LifeServicesCatModel $LifeServicesCatModel){
        $data = $LifeServicesCatModel->getList();
        $this->result($data['msg'], $data['data'], $data['code']);
    }



    /**
     * 获取地区列表
     */
    public function getAreaList(\app\common\model\lifeservices\LifeServicesModel $LifeServicesModel){
        $data = $LifeServicesModel->getAreaList();
        $this->result($data['msg'], $data['data'], $data['code']);
    }



    /**
     * 获取分页列表
     * @ApiMethod GET
     * @param string $cid 分类ID
     * @param string $area_mold 省市区类型:all,province,city,area
     * @param string|int $area_id 省市区id
     * @param string $search 搜索
     */
    public function getPageList(\app\common\model\lifeservices\LifeServicesModel $LifeServicesModel,\app\api\validate\LifeServicesValidate $LifeServicesValidate){
        $params = $this->request->get();
        if(!$LifeServicesValidate->check($params,[],'getPageList')){
            $this->result($LifeServicesValidate->getError(),$params,40001);
        }
        $user_id = $this->auth->id;
        $page = $this->request->request('page');
        $limit = $this->request->request('limit');
        $data = $LifeServicesModel->getPageList($params, $user_id, $page, $limit);
        $this->result($data['msg'], $data['data'], $data['code']);
    }

    /**
     * 获取详情
     */
    public function getDetail(\app\common\model\lifeservices\LifeServicesModel $LifeServicesModel){
        $id = $this->request->request('id');
        if(empty($id)){
            $this->error('请求参数错误');
        }
        $data = $LifeServicesModel->getDetail($id);
        $this->result($data['msg'], $data['data'], $data['code']);
    }

}